<?php 
	include_once $_SERVER["DOCUMENT_ROOT"].'/service/entite/role/RoleEntite.php';
	include_once $_SERVER["DOCUMENT_ROOT"].'/persistence/role/RoleDAO.php';
	include_once $_SERVER["DOCUMENT_ROOT"].'/service/entite/VO.php';
	include_once $_SERVER["DOCUMENT_ROOT"].'/service/uc/gererrole/RoleVO.php';
	
	
	class GererRoleVOAssembler{
		public static function createRoleVO(RoleEntite $role) {
			$roleVO = new RoleVO();
			$roleVO->id = $role->id;
			$roleVO->code = $role->code;
			$roleVO->libelle = $role->libelle;
			return $roleVO;
		}
		
		public static function getEntity(RoleVO $roleVO) {
			if ($roleVO->id == VO::getUnpersistedId()) {
				$role = new RoleEntite();
			} else {
				$role = RoleDAO::getRoleByID($roleVO->id);
			}
			$role->id = $roleVO->id;
			$role->code = $roleVO->code;
			$role->libelle = $roleVO->libelle;
			return $role;
		}
		
		public static function createListeRoleVO($listeRoleEntite) {
			$listeRoleVO = Array();
			foreach ($listeRoleEntite as $roleEntite) {
				$listeRoleVO[] = GererRoleVOAssembler::createRoleVO($roleEntite);
			}
			return $listeRoleVO;
		}
	}

?>